package cn.jdy.plugins.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.plugins.service.LiveService;

/**
 * @title 直播控制类
 * @author lph
 * @time 2017-04-18
 */
@Controller
@RequestMapping("/lives")
public class liveCtrl extends BaseCtrl{
	@Autowired
	private LiveService LiveService;
	
	
	/**
	 * 进入直播首页
	 * @param id
	 * @return
	 */
	@RequestMapping("/liveindex/{id}")
	public ModelAndView liveIndex(@PathVariable Long id) {
		ModelAndView mv = new ModelAndView("/live/liveIndex.jsp");
//		Live live=LiveService.find(id);
//		String json = "{liveId:"+live.getId()+", chatType:'6',status:'"+live.getStatus()+"',liveurl:'"+live.getLiveurl()+"',moviurl:'"+live.getMoviurl()+"',backmoviurl:'"+live.getBackmoviurl()+"'}";
//		WebliveWebsocket websocket=new WebliveWebsocket();
//		//将客户端发送的信息输出给所有在线人员
//    	TextMessage textMessage = new TextMessage(json);
//    	websocket.sendMessageToUsers(textMessage);
		mv.addObject("data", id==null||id==0 ? id : this.LiveService.find(id));
//		Map<String, Object> watchUser = new HashMap<String, Object>();
//		watchUser.put("liveId", id);
//		watchUser.put("openid", "o1hlOtz9UjwYjdx3fAJnKRZFJLPHY");
//		watchUser.put("nickname", "多米尔3");
//		watchUser.put("headimgurl", "http://wx.qlogo.cn/mmopen/POSU1ryY3vmXTHfJaZSoh4ibVwuy59jT3ej8BicfqhDl29aQue9d1FMU3nqhx1DemmPCeeanFo7K90OmtS8bteQsnYDCyVZFVK/0");
//		watchUser.put("sex", "2");
		
//		session.setAttribute("watchUser", watchUser);
		return mv;
	}
}
